package org.fastiot.data.archives

import org.fastiot.data.DataSet

/**
 * 分时趋势
 * Time-Sharing Trend
 */
class Trend {

    String terminalCode

    DataSet dataSet
    static embedded = ['dataSet']

    String metadata
    String contents
    String performances

    Date dateStart
    Date dateEnd

    Date dateCreated
    Date lastUpdated

    static constraints = {
        terminalCode(blank: false)
        dateStart(blank: false)
        dateEnd(blank: false)
        dataSet(blank: false, unique: ["terminalCode", "dateStart"])
        metadata(blank: false)
        contents(nullable: true)
        performances(nullable: true)
        dateCreated()
        lastUpdated()
    }

    static mapping = {
        version false
        metadata type: "text"
        contents type: "text"
        performances type: "text"
        dateStart index: "Timing_DateStart_TerminalCode_DataSet_Index"
        terminalCode index: "Timing_DateStart_TerminalCode_DataSet_Index"
//        dataSet index: "Timing_DateStart_TerminalCode_DataSet_Index" //doesn`t work
    }
}
